/* TCSS 590A - Cybernetics and Systems
 * Group Project - Modeling
 * By Barry Jones, Naren Meadem, Michael Pitts, Yuan Tao
 * Fall 2012, University of Washington, Tacoma
 */


package model.delayed;


/**
 * An Loan account which is taken from bank to pay down payments to investments 
 * Always negative
 * @author Naren Meadem
 * @version Dec 1, 2012
 */


public class Loan implements Account
{

	
	//We get some money from bank with some interest to push it towards Investments account.
	
	// We get the money from the bank invest in some place where we get monthly returns.
	
	// This account has EMI per month outflow to cover up the principle and Interest.
	
	// The time for no of EMI is fixed.
	
	private long totalLoanAmount;
	
	private long EMI;
	
	private long timePeriod;
	
	private long currentValue;
	
	// This can be calculated i guess it differs when we introduce EMI
	private double my_rate;
	
	/**
	 * Comments!
	 * @param total_amount
	 * @param the_EMI
	 * @param time_Period
	 * @param myrate
	 */
	public Loan(final long total_amount, final long the_EMI, 
			final long time_Period, final double myrate)
	{

		totalLoanAmount = total_amount;
		EMI = the_EMI;
		timePeriod = time_Period;
		my_rate = myrate;
		currentValue = -totalLoanAmount;
	}
	
	
	public long getValue() {return currentValue;}
	
	public long getTimeperiod() {return timePeriod;}
	
	public long getEMI() {return EMI;}
	
	public void changeValue(final long the_value) {currentValue += the_value;}
	
	public Event deposit(final long the_value, final long the_time) 
	{
		return new Event(the_value, the_time, this);
	}
	
	public Event withdraw(final long the_value, final long the_time)
	{
		
		//not sure wht to keep as we cannot withdraw from a loan account
		return null;
	}
	
	public double getRate() {return my_rate;}
	
	@Override public boolean inLegalState()
	{
		return getValue() <= 0;
	}
	
	
	//it should its EMI but which should fall under expenses and the account should get the EMI's on time
	public void addInterest()
	{
         
	}
	
}
